package com.collection.linkedhashsets;

import java.util.LinkedHashSet;

public class GetSizeOfJavaLinkedHashSetExample {
	 public static void main(String[] args) {
		 
		    //create LinkedHashSet object
		    LinkedHashSet lhashSet = new LinkedHashSet();
		 
		    /*
		      To get the size of LinkedHashSet use
		      int size() method of LinkedHashSet class. It returns the number of elements
		      stored in LinkedHashSet object.    
		    */
		    System.out.println("Size of LinkedHashSet : " + lhashSet.size());
		 
		    //add elements to LinkedHashSet object
		    lhashSet.add(new Integer("1"));
		    lhashSet.add(new Integer("2"));
		    lhashSet.add(new Integer("3"));
		 
		    System.out.println("Size of LinkedHashSet after addition : " + lhashSet.size());
		 
		    //remove one element from LinkedHashSet using remove method
		    lhashSet.remove(new Integer("1"));
		    System.out.println("Size of LinkedHashSet after removal : " + lhashSet.size());
		  }
}
